home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / general / plotting / imagetoo / imagetl1.lha / Imagetool / HDF / df.h < prev    next >
Encoding:
C/C++ Source or Header  |  1990-09-20  |  11.5 KB  |  271 lines

  1. /*****************************************************************************
  2. *              NCSA HDF version 3.10
  3. *                July 1, 1990
  4. *
  5. * NCSA HDF Version 3.10 source code and documentation are in the public
  6. * domain.  Specifically, we give to the public domain all rights for future
  7. * licensing of the source code, all resale rights, and all publishing rights.
  8. * We ask, but do not require, that the following message be included in all
  9. * derived works:
  10. * Portions developed at the National Center for Supercomputing Applications at
  11. * the University of Illinois at Urbana-Champaign.
  12. * THE UNIVERSITY OF ILLINOIS GIVES NO WARRANTY, EXPRESSED OR IMPLIED, FOR THE
  13. * SOFTWARE AND/OR DOCUMENTATION PROVIDED, INCLUDING, WITHOUT LIMITATION,
  14. * WARRANTY OF MERCHANTABILITY AND WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE
  15. *****************************************************************************/
  16.  
  17. #ifdef RCSID
  18. static char RcsId[] = "@(#)$Revision: 3.2 $"
  19. #endif
  20. /*
  21. $Header: /pita/work/HDF/dev/RCS/src/df.h,v 3.2 90/05/17 17:12:32 clow beta $
  22. $Log:    df.h,v $
  23.  * Revision 3.2  90/05/17  17:12:32  clow
  24.  * removed #include <fortran.h> which has migrated to dfi.h
  25.  * 
  26. */
  27. /*-----------------------------------------------------------------------------
  28.  * File:    df.h
  29.  * Purpose: header file for HDF routines
  30.  * Invokes: dfi.h
  31.  * Contents: 
  32.  *  Structure definitions: DFddh, DFdd, DFdesc, DFdle, DF, DFdi, DFdata
  33.  *  Procedure type definitions
  34.  *  Global variables
  35.  *  Tag definitions
  36.  *  Error return codes
  37.  *  Logical constants
  38.  * Remarks: This file is included with user programs
  39.  *          Since it includes stdio.h etc., do not include these after df.h
  40.  *---------------------------------------------------------------------------*/
  41.  
  42.  
  43. #ifndef DFTAG_NULL              /* avoid re-inclusion */
  44.  
  45. /* include DF (internal) header information */
  46. #include "dfi.h"
  47.  
  48. /*-------------------------------------------------------------------------*/
  49. /*                      Type declarations                                   */
  50.  
  51. typedef struct DFddh {        /*format of data descriptor headers in file*/
  52.     int16 dds;            /* number of dds in header block */
  53.     int32 next;            /* offset of next header block */
  54. } DFddh;
  55.  
  56. typedef struct DFdd {        /* format of data descriptors as in file */
  57.     uint16 tag;            /* data tag */
  58.     uint16 ref;            /* data reference number */
  59.     int32 offset;        /* offset of data element in file */
  60.     int32 length;        /* number of bytes */
  61. } DFdd;
  62.  
  63. /* descriptor structure is same as dd structure.  ###Note: may be changed */
  64. #define DFdesc DFdd
  65.  
  66. /* DLE is the internal structure which stores data descriptor information */
  67. /* It is a linked list of DDs */
  68. typedef struct DFdle {        /* Data List element */
  69.     struct DFdle *next;        /* link to next dle */
  70.     DFddh ddh;            /* To store headers */
  71.     DFdd dd[1];            /* dummy size */
  72. } DFdle;
  73.  
  74. /* DF is the internal structure associated with each DF file */
  75. /* It holds information associated with the file as a whole */
  76. /* ### Note: there are hooks for having multiple DF files open at a time */
  77. typedef struct DF {
  78.     DFdle *list;        /* Pointer to the DLE list */
  79.     DFdle *last_dle;        /* last_dle and last_dd are used in searches */
  80.                 /* to indicate element returned */
  81.                 /* by previous call to DFfind */
  82.     int type;            /* 0= not in use, 1= normal, -1 = multiple */
  83.                 /* this is a hook for when */
  84.                 /* multiple files are open */
  85.     int access;            /* permitted access types: */
  86.                 /* 0=none, 1=r, 2=w, 3=r/w */
  87.     int changed;        /* True if anything in DDs modified */
  88.                 /* since last write */
  89.     uint16 last_tag;        /* Last tag searched for by DFfind */
  90.     uint16 last_ref;        /* Last reference number searched for */
  91.     int last_dd;        /* see last_dle */
  92.     int defdds;            /* default numer of DD's in each block */
  93.     int up_access;        /* access permissions to element being */
  94.                 /* read/updated. Used by DFstart */
  95.     DFdd *up_dd;        /* DD of element being read/updated, */
  96.                 /* used by DFstart */
  97.     /* file handle is a file pointer or file descriptor depending on whether */
  98.     /* we use buffered or unbuffered i/o */
  99. #ifdef DF_BUFFIO
  100.     FILE *file;            /* file pointer */
  101. #else /*DF_BUFFIO*/
  102.     int file;            /* file descriptor */
  103. #endif /*DF_BUFFIO*/
  104. } DF;
  105.  
  106.  
  107. typedef struct DFdi {   /* data identifier: specifies data element uniquely */
  108.     uint16 tag;
  109.     uint16 ref;
  110. } DFdi;
  111.  
  112.  
  113.  
  114. typedef struct DFdata { /* structure for returning status information */
  115.     int version;        /* version number of program */
  116. } DFdata;
  117.  
  118. /*--------------------------------------------------------------------------*/
  119. /*                          Procedure types                                 */
  120.  
  121. #ifndef VMS
  122. DF *DFopen();
  123. int32 DFgetelement(), DFread(), DFseek(), DFwrite();
  124. uint16 DFnewref();
  125. char *DFIgetspace(), *DFIfreespace(), *DFIf2cstring();
  126. #else /*VMS*/
  127.             /* for VMS need to prepend _ to avoid name conflict with Fortran */
  128. DF *_DFopen();
  129. int32 _DFgetelement(), _DFread(), _DFseek(), _DFwrite();
  130. uint16 _DFnewref();
  131. char *_DFIgetspace(), *_DFIfreespace(), *_DFIf2cstring();
  132. #endif /*VMS*/
  133.  
  134. /*--------------------------------------------------------------------------*/
  135. /*                          Global Variables                                */
  136.  
  137. #ifndef DFMASTER
  138. extern
  139. #endif /*DFMASTER*/
  140. int DFerror;            /* Error code for DF routines */
  141.  
  142. /*--------------------------------------------------------------------------*/
  143. /*                           Tag Definitions                                */
  144.  
  145. #define DFREF_WILDCARD ((uint16)0) /* wildcard ref for searches */
  146.  
  147. #define DFTAG_WILDCARD ((uint16)0) /* wildcard tag for searches */
  148. #define DFTAG_NULL  ((uint16)1)    /* empty DD */
  149.  
  150. /* utility set */
  151. #define DFTAG_FID   ((uint16)100) /* File identifier */
  152. #define DFTAG_FD    ((uint16)101) /* File description */
  153. #define DFTAG_TID   ((uint16)102) /* Tag identifier */
  154. #define DFTAG_TD    ((uint16)103) /* Tag descriptor */
  155. #define DFTAG_DIL   ((uint16)104) /* data identifier label */
  156. #define DFTAG_DIA   ((uint16)105) /* data identifier annotation */
  157. #define DFTAG_NT    ((uint16)106) /* number type */
  158. #define DFTAG_MT    ((uint16)107) /* machine type */
  159.  
  160. /* raster-8 set */
  161. #define DFTAG_ID8   ((uint16)200) /* 8-bit Image dimension */
  162. #define DFTAG_IP8   ((uint16)201) /* 8-bit Image palette */
  163. #define DFTAG_RI8   ((uint16)202) /* Raster-8 image */
  164. #define DFTAG_CI8   ((uint16)203) /* RLE compressed 8-bit image */
  165. #define DFTAG_II8   ((uint16)204) /* IMCOMP compressed 8-bit image */
  166.  
  167. /* Raster Image set */
  168. #define DFTAG_ID    ((uint16)300) /* Image DimRec */
  169. #define DFTAG_LUT   ((uint16)301) /* Image Palette */
  170. #define DFTAG_RI    ((uint16)302) /* Raster Image */
  171. #define DFTAG_CI    ((uint16)303) /* Compressed Image */
  172.  
  173. #define DFTAG_RIG   ((uint16)306) /* Raster Image Group */
  174. #define DFTAG_LD    ((uint16)307) /* Palette DimRec */
  175. #define DFTAG_MD    ((uint16)308) /* Matte DimRec */
  176. #define DFTAG_MA    ((uint16)309) /* Matte Data */
  177. #define DFTAG_CCN   ((uint16)310) /* color correction */
  178. #define DFTAG_CFM   ((uint16)311) /* color format */
  179. #define DFTAG_AR    ((uint16)312) /* aspect ratio */
  180.  
  181. #define DFTAG_DRAW  ((uint16)400) /* Draw these images in sequence */
  182. #define DFTAG_RUN   ((uint16)401) /* run this as a program/script */
  183.  
  184. #define DFTAG_XYP   ((uint16)500) /* x-y position */
  185. #define DFTAG_MTO   ((uint16)501) /* machine-type override */
  186.  
  187. /* Tektronix */
  188. #define DFTAG_T14   ((uint16)602) /* TEK 4014 data */
  189. #define DFTAG_T105  ((uint16)603) /* TEK 4105 data */
  190.  
  191. /* Scientific Data set */
  192. #define DFTAG_SDG   ((uint16)700) /* Scientific Data Group */
  193. #define DFTAG_SDD   ((uint16)701) /* Scientific Data DimRec */
  194. #define DFTAG_SD    ((uint16)702) /* Scientific Data */
  195. #define DFTAG_SDS   ((uint16)703) /* Scales */
  196. #define DFTAG_SDL   ((uint16)704) /* Labels */
  197. #define DFTAG_SDU   ((uint16)705) /* Units */
  198. #define DFTAG_SDF   ((uint16)706) /* Formats */
  199. #define DFTAG_SDM   ((uint16)707) /* Max/Min */
  200. #define DFTAG_SDC   ((uint16)708) /* Coord sys */
  201. #define DFTAG_SDT   ((uint16)709) /* Transpose */
  202.  
  203. /* compression schemes */
  204. #define DFTAG_RLE   ((uint16)11) /* run length encoding */
  205. #define DFTAG_IMC   ((uint16)12) /* IMCOMP compression */
  206.  
  207. /*--------------------------------------------------------------------------*/
  208. /*                          Error Return Codes                              */
  209.  
  210. #define DFE_NOERROR     0   /* No error */
  211. #define DFE_FNF         -1  /* File not found error */
  212. #define DFE_DENIED      -2  /* Access to file denied */
  213. #define DFE_ALROPEN     -3  /* File already open */
  214. #define DFE_TOOMANY     -4  /* Too Many DF's or files open */
  215. #define DFE_BADNAME     -5  /* Bad file name on open */
  216. #define DFE_BADACC      -6  /* Bad file access mode */
  217. #define DFE_BADOPEN     -7  /* Other open error */
  218. #define DFE_NOTOPEN     -8  /* File can't be closed 'cause it isn't open */
  219. #define DFE_CANTCLOSE   -9  /* fclose wouldn't work! */
  220. #define DFE_DFNULL      -10 /* DF is a null pointer */
  221. #define DFE_ILLTYPE     -11 /* DF has an illegal type: internal error */
  222. #define DFE_UNSUPPORTED -12 /* Feature not currently supported */
  223. #define DFE_BADDDLIST   -13 /* The DD list is non-existent: internal error */
  224. #define DFE_NOTDFFILE   -14 /* This is not a DF file and it is not 0 length */
  225. #define DFE_SEEDTWICE   -15 /* The DD list already seeded: internal error */
  226. #define DFE_NOSPACE     -16 /* Malloc failed */
  227. #define DFE_NOSUCHTAG   -17 /* There is no such tag in the file: search failed*/
  228. #define DFE_READERROR   -18 /* There was a read error */
  229. #define DFE_WRITEERROR  -19 /* There was a write error */
  230. #define DFE_SEEKERROR   -20 /* There was a seek error */
  231. #define DFE_NOFREEDD    -21 /* There are no free DD's left: internal error */
  232. #define DFE_BADTAG      -22 /* illegal WILDCARD tag */
  233. #define DFE_BADREF      -23 /* illegal WILDCARD reference # */
  234. #define DFE_RDONLY      -24 /* The DF is read only */
  235. #define DFE_BADCALL     -25 /* Calls in wrong order */
  236. #define DFE_BADPTR      -26 /* NULL ptr argument */
  237. #define DFE_BADLEN      -27 /* negative len specified */
  238. #define DFE_BADSEEK     -28 /* Attempt to seek past end of element */
  239. #define DFE_NOMATCH     -29 /* No (more) DDs which match specified tag/ref */
  240. #define DFE_NOTINSET    -30 /* Warning: Set contained unknown tag: ignored */
  241. #define DFE_BADDIM      -31 /* negative or zero dimensions specified */
  242. #define DFE_BADOFFSET   -32 /* Illegal offset specified */
  243. #define DFE_BADSCHEME   -33 /* Unknown compression scheme specified */
  244. #define DFE_NODIM       -34 /* No dimension record associated with image */
  245. #define DFE_NOTENOUGH   -35 /* space provided insufficient for size of data */
  246. #define DFE_NOVALS      -36 /* Values not available */
  247. #define DFE_CORRUPT     -37 /* File is corrupted */
  248. #define DFE_BADCONV     -37 /* Don't know how to convert data type */
  249. #define DFE_BADFP       -38 /* The file contained an illegal floating point no*/
  250. #define DFE_NOREF       -39 /* no more reference numbers are available */
  251. #define DFE_BADDATATYPE -40 /* unknown or unavailable data type specified */
  252. #define DFE_BADMCTYPE   -41 /* unknown or unavailable machine type specified */
  253. #define DFE_BADNUMTYPE  -42 /* unknown or unavailable number type specified */
  254. #define DFE_BADORDER    -43 /* unknown or illegal array order specified */
  255. #define DFE_NOTIMPL     -44 /* This feature not yet implemented */
  256.  
  257. /*--------------------------------------------------------------------------*/
  258. /*                          Logical Constants                               */
  259.  
  260. #define DFACC_READ      1   /* Read Access */
  261. #define DFACC_WRITE     2   /* Write Access */
  262. #define DFACC_CREATE    4   /* force file to be created */
  263. #define DFACC_ALL       7   /* the logical and of all the above values */
  264.  
  265. #endif /*DFTAG_NULL*/
  266.